package com.ruoyi.supplier.controller;

import java.util.List;
import java.io.IOException;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.supplier.domain.SupShopInfo;
import com.ruoyi.supplier.service.ISupShopInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 店铺信息Controller
 * 
 * @author zjf
 * @date 2025-11-05
 */
@RestController
@RequestMapping("/info")
public class SupShopInfoController extends BaseController
{
    @Autowired
    private ISupShopInfoService supShopInfoService;

    /**
     * 查询店铺信息列表
     */
    @RequiresPermissions("system:info:list")
    @GetMapping("/list")
    public TableDataInfo list(SupShopInfo supShopInfo)
    {
        startPage();
        List<SupShopInfo> list = supShopInfoService.selectSupShopInfoList(supShopInfo);
        return getDataTable(list);
    }

    /**
     * 导出店铺信息列表
     */
    @RequiresPermissions("system:info:export")
    @Log(title = "店铺信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SupShopInfo supShopInfo)
    {
        List<SupShopInfo> list = supShopInfoService.selectSupShopInfoList(supShopInfo);
        ExcelUtil<SupShopInfo> util = new ExcelUtil<SupShopInfo>(SupShopInfo.class);
        util.exportExcel(response, list, "店铺信息数据");
    }

    /**
     * 获取店铺信息详细信息
     */
    @RequiresPermissions("system:info:query")
    @GetMapping(value = "/{shopId}")
    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
    {
        return success(supShopInfoService.selectSupShopInfoByShopId(shopId));
    }

    /**
     * 新增店铺信息
     */
    @RequiresPermissions("system:info:add")
    @Log(title = "店铺信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SupShopInfo supShopInfo)
    {
        return toAjax(supShopInfoService.insertSupShopInfo(supShopInfo));
    }

    /**
     * 修改店铺信息
     */
    @RequiresPermissions("system:info:edit")
    @Log(title = "店铺信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SupShopInfo supShopInfo)
    {
        return toAjax(supShopInfoService.updateSupShopInfo(supShopInfo));
    }

    /**
     * 删除店铺信息
     */
    @RequiresPermissions("system:info:remove")
    @Log(title = "店铺信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopIds}")
    public AjaxResult remove(@PathVariable Long[] shopIds)
    {
        return toAjax(supShopInfoService.deleteSupShopInfoByShopIds(shopIds));
    }
}
